package com.ruoyi.his.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.his.domain.NewHisRegistration;
import com.ruoyi.his.service.INewHisRegistrationService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * newregistrationController
 * 
 * @author ruoyi
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/newregistration/newregistration")
public class NewHisRegistrationController extends BaseController
{
    @Autowired
    private INewHisRegistrationService newHisRegistrationService;

    /**
     * 查询newregistration列表
     */

    @GetMapping("/list")
    public TableDataInfo list(NewHisRegistration newHisRegistration)
    {
        startPage();
        List<NewHisRegistration> list = newHisRegistrationService.selectNewHisRegistrationList(newHisRegistration);
        return getDataTable(list);
    }

    /**
     * 导出newregistration列表
     */

    @Log(title = "newregistration", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NewHisRegistration newHisRegistration)
    {
        List<NewHisRegistration> list = newHisRegistrationService.selectNewHisRegistrationList(newHisRegistration);
        ExcelUtil<NewHisRegistration> util = new ExcelUtil<NewHisRegistration>(NewHisRegistration.class);
        util.exportExcel(response, list, "newregistration数据");
    }

    /**
     * 获取newregistration详细信息
     */

    @GetMapping(value = "/{registrationId}")
    public AjaxResult getInfo(@PathVariable("registrationId") Long registrationId)
    {
        return AjaxResult.success(newHisRegistrationService.selectNewHisRegistrationByRegistrationId(registrationId));
    }

    /**
     * 新增newregistration
     */

    @Log(title = "newregistration", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NewHisRegistration newHisRegistration)
    {
        return toAjax(newHisRegistrationService.insertNewHisRegistration(newHisRegistration));
    }

    /**
     * 修改newregistration
     */

    @Log(title = "newregistration", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NewHisRegistration newHisRegistration)
    {
        return toAjax(newHisRegistrationService.updateNewHisRegistration(newHisRegistration));
    }

    /**
     * 删除newregistration
     */

    @Log(title = "newregistration", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registrationIds}")
    public AjaxResult remove(@PathVariable Long[] registrationIds)
    {
        return toAjax(newHisRegistrationService.deleteNewHisRegistrationByRegistrationIds(registrationIds));
    }
    @PostMapping("/newone")
    public AjaxResult newone(@RequestBody NewHisRegistration newHisRegistration)
    {
        return AjaxResult.success(newHisRegistrationService.newone(newHisRegistration));
    }
    //根据患者列表查询挂号记录
    @RequestMapping("/getListByPatientId")
    public AjaxResult getListByPatientId(@RequestBody Long[] patientId)
    {
        return AjaxResult.success(newHisRegistrationService.getListByPatientId(patientId));
    }
}
